{{- define "setup.statefulsets" }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: seldon-v2-controller-manager
  namespace: '{{ .Release.Namespace }}'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: seldon-v2-leader-election-role
  namespace: '{{ .Release.Namespace }}'
rules:
- apiGroups:
  - ""
  resources:
  - configmaps
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
- apiGroups:
  - ""
  resources:
  - events
  verbs:
  - create
  - patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: seldon-v2-manager-role
  namespace: '{{ .Release.Namespace }}'
rules:
- apiGroups:
  - ""
  resources:
  - configmaps
  - secrets
  - serviceaccounts
  - services
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - ""
  resources:
  - events
  verbs:
  - create
  - patch
- apiGroups:
  - apps
  resources:
  - deployments
  - statefulsets
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - apps
  resources:
  - deployments/status
  - statefulsets/status
  verbs:
  - get
- apiGroups:
  - discovery.k8s.io
  resources:
  - endpointslices
  verbs:
  - list
  - watch
- apiGroups:
  - mlops.seldon.io
  resources:
  - experiments
  - models
  - pipelines
  - seldonconfigs
  - seldonruntimes
  - serverconfigs
  - servers
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - mlops.seldon.io
  resources:
  - experiments/finalizers
  - models/finalizers
  - pipelines/finalizers
  - seldonconfigs/finalizers
  - seldonruntimes/finalizers
  - serverconfigs/finalizers
  - servers/finalizers
  verbs:
  - update
- apiGroups:
  - mlops.seldon.io
  resources:
  - experiments/status
  - models/status
  - pipelines/status
  - seldonconfigs/status
  - seldonruntimes/status
  - serverconfigs/status
  - servers/status
  verbs:
  - get
  - patch
  - update
- apiGroups:
  - rbac.authorization.k8s.io
  resources:
  - rolebindings
  - roles
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - v1
  resources:
  - serviceaccounts
  - services
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - v1
  resources:
  - services/status
  verbs:
  - get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  creationTimestamp: null
  name: seldon-v2-manager-tls-role
  namespace: '{{ .Release.Namespace }}'
rules:
- apiGroups:
  - ""
  resources:
  - secrets
  verbs:
  - get
  - list
  - watch
---
{{- if and (not .Values.controller.skipClusterRoleCreation) (or .Values.controller.clusterwide .Values.controller.watchNamespaces) -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: seldon-v2-manager-role
rules:
- apiGroups:
  - ""
  resources:
  - configmaps
  - secrets
  - serviceaccounts
  - services
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - ""
  resources:
  - events
  verbs:
  - create
  - patch
- apiGroups:
  - apps
  resources:
  - deployments
  - statefulsets
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - apps
  resources:
  - deployments/status
  - statefulsets/status
  verbs:
  - get
- apiGroups:
  - discovery.k8s.io
  resources:
  - endpointslices
  verbs:
  - list
  - watch
- apiGroups:
  - mlops.seldon.io
  resources:
  - experiments
  - models
  - pipelines
  - seldonconfigs
  - seldonruntimes
  - serverconfigs
  - servers
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - mlops.seldon.io
  resources:
  - experiments/finalizers
  - models/finalizers
  - pipelines/finalizers
  - seldonconfigs/finalizers
  - seldonruntimes/finalizers
  - serverconfigs/finalizers
  - servers/finalizers
  verbs:
  - update
- apiGroups:
  - mlops.seldon.io
  resources:
  - experiments/status
  - models/status
  - pipelines/status
  - seldonconfigs/status
  - seldonruntimes/status
  - serverconfigs/status
  - servers/status
  verbs:
  - get
  - patch
  - update
- apiGroups:
  - rbac.authorization.k8s.io
  resources:
  - rolebindings
  - roles
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - v1
  resources:
  - serviceaccounts
  - services
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - v1
  resources:
  - services/status
  verbs:
  - get
---
{{- end }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: seldon-v2-leader-election-rolebinding
  namespace: '{{ .Release.Namespace }}'
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: seldon-v2-leader-election-role
subjects:
- kind: ServiceAccount
  name: seldon-v2-controller-manager
  namespace: '{{ .Release.Namespace }}'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: seldon-v2-manager-rolebinding
  namespace: '{{ .Release.Namespace }}'
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: seldon-v2-manager-role
subjects:
- kind: ServiceAccount
  name: seldon-v2-controller-manager
  namespace: '{{ .Release.Namespace }}'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: seldon-v2-manager-tls-rolebinding
  namespace: '{{ .Release.Namespace }}'
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: seldon-v2-manager-tls-role
subjects:
- kind: ServiceAccount
  name: seldon-v2-controller-manager
  namespace: '{{ .Release.Namespace }}'
---
{{- if or .Values.controller.clusterwide .Values.controller.watchNamespaces -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: seldon-v2-manager-rolebinding-{{ .Release.Namespace }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: seldon-v2-manager-role
subjects:
- kind: ServiceAccount
  name: seldon-v2-controller-manager
  namespace: '{{ .Release.Namespace }}'
---
{{- end }}
apiVersion: v1
data:
  controller_manager_config.yaml: |
    apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
    kind: ControllerManagerConfig
    health:
      healthProbeBindAddress: :8081
    metrics:
      bindAddress: 127.0.0.1:8080
    webhook:
      port: 9443
    leaderElection:
      leaderElect: true
      resourceName: e98130ae.seldon.io
kind: ConfigMap
metadata:
  name: seldon-manager-config
  namespace: '{{ .Release.Namespace }}'
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    control-plane: v2-controller-manager
  name: seldon-v2-controller-manager
  namespace: '{{ .Release.Namespace }}'
spec:
  replicas: 1
  selector:
    matchLabels:
      control-plane: v2-controller-manager
  template:
    metadata:
      annotations: {{- toYaml .Values.controller.annotations | nindent  8
        }}
      labels:
        control-plane: v2-controller-manager
    spec:
      containers:
      - args:
        - --health-probe-bind-address=:8081
        - --leader-elect
        - --watch-namespaces=$(WATCH_NAMESPACES)
        - --namespace=$(POD_NAMESPACE)
        - --clusterwide=$(CLUSTERWIDE)
        - --log-level=$(LOG_LEVEL)
        - --use-deployments-for-servers=$(USE_DEPLOYMENTS_FOR_SERVERS)
        command:
        - /manager
        env:
        - name: CLUSTERWIDE
          value: '{{ .Values.controller.clusterwide }}'
        - name: CONTROL_PLANE_SECURITY_PROTOCOL
          value: '{{ .Values.security.controlplane.protocol }}'
        - name: CONTROL_PLANE_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.client.secret }}'
        - name: CONTROL_PLANE_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.client.serverValidationSecret
            }}'
        - name: CONTROL_PLANE_CLIENT_TLS_KEY_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.keyPath }}'
        - name: CONTROL_PLANE_CLIENT_TLS_CRT_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.crtPath }}'
        - name: CONTROL_PLANE_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.caPath }}'
        - name: CONTROL_PLANE_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.serverCaPath }}'
        - name: LOG_LEVEL
          value: '{{ hasKey .Values.controller "logLevel" | ternary .Values.controller.logLevel
            .Values.logging.logLevel }}'
        - name: WATCH_NAMESPACES
          value: '{{ join "," .Values.controller.watchNamespaces }}'
        - name: USE_DEPLOYMENTS_FOR_SERVERS
          value: '{{ .Values.useDeploymentsForServers }}'
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        image: '{{ .Values.controller.image.registry }}/{{ .Values.controller.image.repository
          }}:{{ .Values.controller.image.tag }}'
        imagePullPolicy: '{{ .Values.controller.image.pullPolicy }}'
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
          initialDelaySeconds: 15
          periodSeconds: 20
        name: manager
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
          initialDelaySeconds: 5
          periodSeconds: 10
        resources:
          limits:
            memory: '{{ .Values.controller.resources.memory }}'
          requests:
            cpu: '{{ .Values.controller.resources.cpu }}'
            memory: '{{ .Values.controller.resources.memory }}'
        securityContext:
          allowPrivilegeEscalation: false
{{- with .Values.imagePullSecrets }}
      imagePullSecrets:
      {{- toYaml . | nindent 8 }}
{{- end }}
      securityContext: {{- toYaml .Values.controller.securityContext
        | nindent 8 }}
      serviceAccountName: seldon-v2-controller-manager
      terminationGracePeriodSeconds: 10
---
apiVersion: mlops.seldon.io/v1alpha1
kind: SeldonConfig
metadata:
  name: default
  namespace: '{{ .Release.Namespace }}'
spec:
  components:
  - annotations: {{- toYaml .Values.scheduler.annotations | nindent
      8 }}
    labels: {{- toYaml .Values.scheduler.labels | nindent 8 }}
    name: seldon-scheduler
    podSpec:
      containers:
      - args:
        - --pipeline-gateway-host=seldon-pipelinegateway
        - --tracing-config-path=/mnt/tracing/tracing.json
        - --db-path=/mnt/scheduler/db
        - --allow-plaintxt=$(ALLOW_PLAINTXT)
        - --kafka-config-path=/mnt/kafka/kafka.json
        - --scaling-config-path=/mnt/scaling/scaling.yaml
        - --scheduler-ready-timeout-seconds=$(SCHEDULER_READY_TIMEOUT_SECONDS)
        - --server-packing-enabled=$(SERVER_PACKING_ENABLED)
        - --server-packing-percentage=$(SERVER_PACKING_PERCENTAGE)
        - --envoy-accesslog-path=$(ENVOY_ACCESSLOG_PATH)
        - --enable-envoy-accesslog=$(ENABLE_ENVOY_ACCESSLOG)
        - --include-successful-requests-envoy-accesslog=$(INCLUDE_SUCCESSFUL_REQUESTS_ENVOY_ACCESSLOG)
        - --enable-model-autoscaling=$(ENABLE_MODEL_AUTOSCALING)
        - --enable-server-autoscaling=$(ENABLE_SERVER_AUTOSCALING)
        - --log-level=$(LOG_LEVEL)
        - --health-probe-port=$(HEALTH_PROBE_PORT)
        - --enable-pprof=$(ENABLE_PPROF)
        - --pprof-port=$(PPROF_PORT)
        - --pprof-block-rate=$(PPROF_BLOCK_RATE)
        - --pprof-mutex-rate=$(PPROF_MUTEX_RATE)
        - --retry-creating-failed-pipelines-tick=$(RETRY_CREATING_FAILED_PIPELINES_TICK)
        - --retry-deleting-failed-pipelines-tick=$(RETRY_DELETING_FAILED_PIPELINES_TICK)
        - --max-retry-failed-pipelines=$(MAX_RETRY_FAILED_PIPELINES)
        command:
        - /bin/scheduler
        env:
        - name: CONTROL_PLANE_SECURITY_PROTOCOL
          value: '{{ .Values.security.controlplane.protocol }}'
        - name: CONTROL_PLANE_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.server.secret }}'
        - name: CONTROL_PLANE_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.server.clientValidationSecret
            }}'
        - name: CONTROL_PLANE_SERVER_TLS_KEY_LOCATION
          value: '{{ .Values.security.controlplane.ssl.server.keyPath }}'
        - name: CONTROL_PLANE_SERVER_TLS_CRT_LOCATION
          value: '{{ .Values.security.controlplane.ssl.server.crtPath }}'
        - name: CONTROL_PLANE_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.server.caPath }}'
        - name: CONTROL_PLANE_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.server.clientCaPath }}'
        - name: ENVOY_SECURITY_PROTOCOL
          value: '{{ .Values.security.envoy.protocol }}'
        - name: ENVOY_UPSTREAM_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.upstream.client.secret }}'
        - name: ENVOY_UPSTREAM_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.upstream.client.serverValidationSecret
            }}'
        - name: ENVOY_UPSTREAM_CLIENT_TLS_KEY_LOCATION
          value: '{{ .Values.security.envoy.ssl.upstream.client.keyPath }}'
        - name: ENVOY_UPSTREAM_CLIENT_TLS_CRT_LOCATION
          value: '{{ .Values.security.envoy.ssl.upstream.client.crtPath }}'
        - name: ENVOY_UPSTREAM_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.upstream.client.caPath }}'
        - name: ENVOY_UPSTREAM_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.upstream.client.serverCaPath }}'
        - name: ENVOY_DOWNSTREAM_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.downstream.server.secret }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.downstream.server.clientValidationSecret
            }}'
        - name: ENVOY_DOWNSTREAM_SERVER_TLS_KEY_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.server.keyPath }}'
        - name: ENVOY_DOWNSTREAM_SERVER_TLS_CRT_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.server.crtPath }}'
        - name: ENVOY_DOWNSTREAM_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.server.caPath }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.server.clientCaPath }}'
        - name: SCHEDULER_READY_TIMEOUT_SECONDS
          value: '{{ .Values.scheduler.schedulerReadyTimeoutSeconds }}'
        - name: SERVER_PACKING_ENABLED
          value: '{{ .Values.autoscaling.serverPackingEnabled }}'
        - name: SERVER_PACKING_PERCENTAGE
          value: '{{ .Values.autoscaling.serverPackingPercentage }}'
        - name: ENVOY_ACCESSLOG_PATH
          value: '{{ .Values.envoy.accesslogPath }}'
        - name: ENABLE_ENVOY_ACCESSLOG
          value: '{{ .Values.envoy.enableAccesslog }}'
        - name: INCLUDE_SUCCESSFUL_REQUESTS_ENVOY_ACCESSLOG
          value: '{{ .Values.envoy.includeSuccessfulRequests }}'
        - name: ENABLE_MODEL_AUTOSCALING
          value: '{{ .Values.autoscaling.autoscalingModelEnabled }}'
        - name: ENABLE_SERVER_AUTOSCALING
          value: '{{ .Values.autoscaling.autoscalingServerEnabled }}'
        - name: LOG_LEVEL
          value: '{{ hasKey .Values.scheduler "logLevel" | ternary .Values.scheduler.logLevel
            .Values.logging.logLevel }}'
        - name: MODELGATEWAY_MAX_NUM_CONSUMERS
          value: '{{ .Values.modelgateway.maxNumConsumers }}'
        - name: PIPELINEGATEWAY_MAX_NUM_CONSUMERS
          value: '{{ .Values.pipelinegateway.maxNumConsumers }}'
        - name: ALLOW_PLAINTXT
          value: "true"
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: HEALTH_PROBE_PORT
          value: "9999"
        - name: ENABLE_PPROF
          value: "false"
        - name: PPROF_PORT
          value: "6060"
        - name: PPROF_BLOCK_RATE
          value: "0"
        - name: PPROF_MUTEX_RATE
          value: "0"
        - name: RETRY_CREATING_FAILED_PIPELINES_TICK
          value: 60s
        - name: RETRY_DELETING_FAILED_PIPELINES_TICK
          value: 60s
        - name: MAX_RETRY_FAILED_PIPELINES
          value: "10"
        image: '{{ .Values.scheduler.image.registry }}/{{ .Values.scheduler.image.repository
          }}:{{ .Values.scheduler.image.tag }}'
        imagePullPolicy: '{{ .Values.scheduler.image.pullPolicy }}'
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /live
            port: health
          initialDelaySeconds: 10
          periodSeconds: 5
        name: scheduler
        ports:
        - containerPort: 9002
          name: xds
        - containerPort: 9004
          name: scheduler
        - containerPort: 9044
          name: scheduler-mtls
        - containerPort: 9005
          name: agent
        - containerPort: 9055
          name: agent-mtls
        - containerPort: 9008
          name: dataflow
        - containerPort: 9999
          name: health
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /ready
            port: health
          initialDelaySeconds: 10
          periodSeconds: 5
        resources:
          limits:
            memory: '{{ .Values.scheduler.resources.memory }}'
          requests:
            cpu: '{{ .Values.scheduler.resources.cpu }}'
            memory: '{{ .Values.scheduler.resources.memory }}'
        volumeMounts:
        - mountPath: /mnt/kafka
          name: kafka-config-volume
        - mountPath: /mnt/scaling
          name: scaling-config-volume
        - mountPath: /mnt/tracing
          name: tracing-config-volume
        - mountPath: /mnt/scheduler
          name: scheduler-state
{{- with .Values.imagePullSecrets }}
      imagePullSecrets:
      {{- toYaml . | nindent 8 }}
{{- end }}
      securityContext: {{- toYaml .Values.scheduler.securityContext
        | nindent 8 }}
      serviceAccountName: seldon-scheduler
      terminationGracePeriodSeconds: 5
      volumes:
      - configMap:
          name: seldon-scaling
        name: scaling-config-volume
      - configMap:
          name: seldon-kafka
        name: kafka-config-volume
      - configMap:
          name: seldon-tracing
        name: tracing-config-volume
    replicas: 1
    volumeClaimTemplates:
    - name: scheduler-state
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: '{{ .Values.scheduler.resources.storage }}'
  - annotations: {{- toYaml .Values.pipelinegateway.annotations | nindent
      8 }}
    labels: {{- toYaml .Values.pipelinegateway.labels | nindent 8 }}
    name: seldon-pipelinegateway
    podSpec:
      containers:
      - args:
        - --http-port=9010
        - --grpc-port=9011
        - --metrics-port=9006
        - --scheduler-host=seldon-scheduler
        - --scheduler-plaintxt-port=$(SELDON_SCHEDULER_PLAINTXT_PORT)
        - --scheduler-tls-port=$(SELDON_SCHEDULER_TLS_PORT)
        - --envoy-host=seldon-mesh
        - --envoy-port=80
        - --kafka-config-path=/mnt/kafka/kafka.json
        - --tracing-config-path=/mnt/tracing/tracing.json
        - --log-level=$(LOG_LEVEL)
        - --health-probe-port=$(HEALTH_PROBE_PORT)
        command:
        - /bin/pipelinegateway
        env:
        - name: KAFKA_SECURITY_PROTOCOL
          value: '{{ .Values.security.kafka.protocol }}'
        - name: KAFKA_SASL_MECHANISM
          value: '{{ .Values.security.kafka.sasl.mechanism }}'
        - name: KAFKA_CLIENT_TLS_ENDPOINT_IDENTIFICATION_ALGORITHM
          value: '{{ .Values.security.kafka.ssl.client.endpointIdentificationAlgorithm
            }}'
        - name: KAFKA_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.kafka.ssl.client.secret }}'
        - name: KAFKA_CLIENT_TLS_KEY_LOCATION
          value: '{{ .Values.security.kafka.ssl.client.keyPath }}'
        - name: KAFKA_CLIENT_TLS_CRT_LOCATION
          value: '{{ .Values.security.kafka.ssl.client.crtPath }}'
        - name: KAFKA_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.kafka.ssl.client.caPath }}'
        - name: KAFKA_CLIENT_SASL_USERNAME
          value: '{{ .Values.security.kafka.sasl.client.username }}'
        - name: KAFKA_CLIENT_SASL_SECRET_NAME
          value: '{{ .Values.security.kafka.sasl.client.secret }}'
        - name: KAFKA_CLIENT_SASL_PASSWORD_LOCATION
          value: '{{ .Values.security.kafka.sasl.client.passwordPath }}'
        - name: KAFKA_BROKER_TLS_SECRET_NAME
          value: '{{ .Values.security.kafka.ssl.client.brokerValidationSecret }}'
        - name: KAFKA_BROKER_TLS_CA_LOCATION
          value: '{{ .Values.security.kafka.ssl.client.brokerCaPath }}'
        - name: SCHEMA_REGISTRY_CONFIG_PATH
          value: '{{ .Values.security.schemaRegistry.configPath }}'
        - name: ENVOY_SECURITY_PROTOCOL
          value: '{{ .Values.security.envoy.protocol }}'
        - name: ENVOY_UPSTREAM_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.upstream.server.secret }}'
        - name: ENVOY_UPSTREAM_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.upstream.server.clientValidationSecret
            }}'
        - name: ENVOY_UPSTREAM_SERVER_TLS_KEY_LOCATION
          value: '{{ .Values.security.envoy.ssl.upstream.server.keyPath }}'
        - name: ENVOY_UPSTREAM_SERVER_TLS_CRT_LOCATION
          value: '{{ .Values.security.envoy.ssl.upstream.server.crtPath }}'
        - name: ENVOY_UPSTREAM_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.upstream.server.caPath }}'
        - name: ENVOY_UPSTREAM_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.upstream.server.clientCaPath }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_MTLS
          value: '{{ .Values.security.envoy.ssl.downstream.client.mtls }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.downstream.client.secret }}'
        - name: ENVOY_DOWNSTREAM_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.downstream.client.serverValidationSecret
            }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_KEY_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.client.keyPath }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_CRT_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.client.crtPath }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.client.caPath }}'
        - name: ENVOY_DOWNSTREAM_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.client.serverCaPath }}'
        - name: CONTROL_PLANE_SECURITY_PROTOCOL
          value: '{{ .Values.security.controlplane.protocol }}'
        - name: CONTROL_PLANE_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.client.secret }}'
        - name: CONTROL_PLANE_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.client.serverValidationSecret
            }}'
        - name: CONTROL_PLANE_CLIENT_TLS_KEY_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.keyPath }}'
        - name: CONTROL_PLANE_CLIENT_TLS_CRT_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.crtPath }}'
        - name: CONTROL_PLANE_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.caPath }}'
        - name: CONTROL_PLANE_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.serverCaPath }}'
        - name: LOG_LEVEL
          value: '{{ hasKey .Values.pipelinegateway "logLevel" | ternary .Values.pipelinegateway.logLevel
            .Values.logging.logLevel }}'
        - name: PIPELINEGATEWAY_MAX_NUM_CONSUMERS
          value: '{{ .Values.pipelinegateway.maxNumConsumers }}'
        - name: SELDON_SCHEDULER_PLAINTXT_PORT
          value: "9004"
        - name: SELDON_SCHEDULER_TLS_PORT
          value: "9044"
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: HEALTH_PROBE_PORT
          value: "9999"
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        image: '{{ .Values.pipelinegateway.image.registry }}/{{ .Values.pipelinegateway.image.repository
          }}:{{ .Values.pipelinegateway.image.tag }}'
        imagePullPolicy: '{{ .Values.pipelinegateway.image.pullPolicy }}'
        lifecycle:
          preStop:
            exec:
              command:
              - /bin/sh
              - -c
              - sleep 2
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /live
            port: health
          periodSeconds: 5
        name: pipelinegateway
        ports:
        - containerPort: 9010
          name: http
          protocol: TCP
        - containerPort: 9011
          name: grpc
          protocol: TCP
        - containerPort: 9006
          name: metrics
          protocol: TCP
        - containerPort: 9999
          name: health
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /ready
            port: health
          periodSeconds: 5
        resources:
          limits:
            memory: '{{ .Values.pipelinegateway.resources.memory }}'
          requests:
            cpu: '{{ .Values.pipelinegateway.resources.cpu }}'
            memory: '{{ .Values.pipelinegateway.resources.memory }}'
        startupProbe:
          failureThreshold: 10
          httpGet:
            path: /startup
            port: health
          initialDelaySeconds: 10
          periodSeconds: 10
        volumeMounts:
        - mountPath: /mnt/kafka
          name: kafka-config-volume
        - mountPath: /mnt/tracing
          name: tracing-config-volume
        - mountPath: /mnt/schema-registry
          name: kafka-schema-volume
          readOnly: true
{{- with .Values.imagePullSecrets }}
      imagePullSecrets:
      {{- toYaml . | nindent 8 }}
{{- end }}
      securityContext: {{- toYaml .Values.pipelinegateway.securityContext
        | nindent 8 }}
      serviceAccountName: seldon-scheduler
      terminationGracePeriodSeconds: 5
      volumes:
      - configMap:
          name: seldon-kafka
        name: kafka-config-volume
      - configMap:
          name: seldon-tracing
        name: tracing-config-volume
      - name: kafka-schema-volume
        secret:
          optional: true
          secretName: confluent-schema
    replicas: 1
  - annotations: {{- toYaml .Values.modelgateway.annotations | nindent
      8 }}
    labels: {{- toYaml .Values.modelgateway.labels | nindent 8 }}
    name: seldon-modelgateway
    podSpec:
      containers:
      - args:
        - --scheduler-host=seldon-scheduler
        - --scheduler-plaintxt-port=$(SELDON_SCHEDULER_PLAINTXT_PORT)
        - --scheduler-tls-port=$(SELDON_SCHEDULER_TLS_PORT)
        - --envoy-host=seldon-mesh
        - --envoy-port=80
        - --kafka-config-path=/mnt/kafka/kafka.json
        - --tracing-config-path=/mnt/tracing/tracing.json
        - --log-level=$(LOG_LEVEL)
        - --health-probe-port=$(HEALTH_PROBE_PORT)
        command:
        - /bin/modelgateway
        env:
        - name: MODELGATEWAY_NUM_WORKERS
          value: '{{ .Values.modelgateway.workers }}'
        - name: KAFKA_DEFAULT_REPLICATION_FACTOR
          value: '{{ .Values.kafka.topics.replicationFactor }}'
        - name: KAFKA_DEFAULT_NUM_PARTITIONS
          value: '{{ .Values.kafka.topics.numPartitions }}'
        - name: CONTROL_PLANE_SECURITY_PROTOCOL
          value: '{{ .Values.security.controlplane.protocol }}'
        - name: CONTROL_PLANE_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.client.secret }}'
        - name: CONTROL_PLANE_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.client.serverValidationSecret
            }}'
        - name: CONTROL_PLANE_CLIENT_TLS_KEY_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.keyPath }}'
        - name: CONTROL_PLANE_CLIENT_TLS_CRT_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.crtPath }}'
        - name: CONTROL_PLANE_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.caPath }}'
        - name: CONTROL_PLANE_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.serverCaPath }}'
        - name: KAFKA_SECURITY_PROTOCOL
          value: '{{ .Values.security.kafka.protocol }}'
        - name: KAFKA_SASL_MECHANISM
          value: '{{ .Values.security.kafka.sasl.mechanism }}'
        - name: KAFKA_CLIENT_TLS_ENDPOINT_IDENTIFICATION_ALGORITHM
          value: '{{ .Values.security.kafka.ssl.client.endpointIdentificationAlgorithm
            }}'
        - name: KAFKA_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.kafka.ssl.client.secret }}'
        - name: KAFKA_CLIENT_TLS_KEY_LOCATION
          value: '{{ .Values.security.kafka.ssl.client.keyPath }}'
        - name: KAFKA_CLIENT_TLS_CRT_LOCATION
          value: '{{ .Values.security.kafka.ssl.client.crtPath }}'
        - name: KAFKA_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.kafka.ssl.client.caPath }}'
        - name: KAFKA_CLIENT_SASL_USERNAME
          value: '{{ .Values.security.kafka.sasl.client.username }}'
        - name: KAFKA_CLIENT_SASL_SECRET_NAME
          value: '{{ .Values.security.kafka.sasl.client.secret }}'
        - name: KAFKA_CLIENT_SASL_PASSWORD_LOCATION
          value: '{{ .Values.security.kafka.sasl.client.passwordPath }}'
        - name: KAFKA_BROKER_TLS_SECRET_NAME
          value: '{{ .Values.security.kafka.ssl.client.brokerValidationSecret }}'
        - name: KAFKA_BROKER_TLS_CA_LOCATION
          value: '{{ .Values.security.kafka.ssl.client.brokerCaPath }}'
        - name: ENVOY_SECURITY_PROTOCOL
          value: '{{ .Values.security.envoy.protocol }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_MTLS
          value: '{{ .Values.security.envoy.ssl.downstream.client.mtls }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.downstream.client.secret }}'
        - name: ENVOY_DOWNSTREAM_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.envoy.ssl.downstream.client.serverValidationSecret
            }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_KEY_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.client.keyPath }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_CRT_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.client.crtPath }}'
        - name: ENVOY_DOWNSTREAM_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.client.caPath }}'
        - name: ENVOY_DOWNSTREAM_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.envoy.ssl.downstream.client.serverCaPath }}'
        - name: LOG_LEVEL
          value: '{{ hasKey .Values.modelgateway "logLevel" | ternary .Values.modelgateway.logLevel
            .Values.logging.logLevel }}'
        - name: MODELGATEWAY_MAX_NUM_CONSUMERS
          value: '{{ .Values.modelgateway.maxNumConsumers }}'
        - name: SCHEMA_REGISTRY_CONFIG_PATH
          value: '{{ .Values.security.schemaRegistry.configPath }}'
        - name: SELDON_SCHEDULER_PLAINTXT_PORT
          value: "9004"
        - name: SELDON_SCHEDULER_TLS_PORT
          value: "9044"
        - name: HEALTH_PROBE_PORT
          value: "9999"
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        image: '{{ .Values.modelgateway.image.registry }}/{{ .Values.modelgateway.image.repository
          }}:{{ .Values.modelgateway.image.tag }}'
        imagePullPolicy: '{{ .Values.modelgateway.image.pullPolicy }}'
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /live
            port: health
          periodSeconds: 5
        name: modelgateway
        ports:
        - containerPort: 9999
          name: health
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /ready
            port: health
          periodSeconds: 5
        resources:
          limits:
            memory: '{{ .Values.modelgateway.resources.memory }}'
          requests:
            cpu: '{{ .Values.modelgateway.resources.cpu }}'
            memory: '{{ .Values.modelgateway.resources.memory }}'
        startupProbe:
          failureThreshold: 10
          httpGet:
            path: /startup
            port: health
          initialDelaySeconds: 10
          periodSeconds: 10
        volumeMounts:
        - mountPath: /mnt/kafka
          name: kafka-config-volume
        - mountPath: /mnt/tracing
          name: tracing-config-volume
        - mountPath: /mnt/schema-registry
          name: kafka-schema-volume
          readOnly: true
{{- with .Values.imagePullSecrets }}
      imagePullSecrets:
      {{- toYaml . | nindent 8 }}
{{- end }}
      securityContext: {{- toYaml .Values.modelgateway.securityContext
        | nindent 8 }}
      serviceAccountName: seldon-scheduler
      terminationGracePeriodSeconds: 5
      volumes:
      - configMap:
          name: seldon-kafka
        name: kafka-config-volume
      - configMap:
          name: seldon-tracing
        name: tracing-config-volume
      - name: kafka-schema-volume
        secret:
          optional: true
          secretName: confluent-schema
    replicas: 1
  - annotations: {{- toYaml .Values.hodometer.annotations | nindent
      8 }}
    labels: {{- toYaml .Values.hodometer.labels | nindent 8 }}
    name: hodometer
    podSpec:
      containers:
      - env:
        - name: METRICS_LEVEL
          value: '{{ .Values.hodometer.metricsLevel }}'
        - name: LOG_LEVEL
          value: '{{ hasKey .Values.hodometer "logLevel" | ternary .Values.hodometer.logLevel
            .Values.logging.logLevel }}'
        - name: EXTRA_PUBLISH_URLS
          value: '{{ .Values.hodometer.extraPublishUrls }}'
        - name: CONTROL_PLANE_SECURITY_PROTOCOL
          value: '{{ .Values.security.controlplane.protocol }}'
        - name: CONTROL_PLANE_CLIENT_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.client.secret }}'
        - name: CONTROL_PLANE_SERVER_TLS_SECRET_NAME
          value: '{{ .Values.security.controlplane.ssl.client.serverValidationSecret
            }}'
        - name: CONTROL_PLANE_CLIENT_TLS_KEY_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.keyPath }}'
        - name: CONTROL_PLANE_CLIENT_TLS_CRT_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.crtPath }}'
        - name: CONTROL_PLANE_CLIENT_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.caPath }}'
        - name: CONTROL_PLANE_SERVER_TLS_CA_LOCATION
          value: '{{ .Values.security.controlplane.ssl.client.serverCaPath }}'
        - name: PUBLISH_URL
          value: http://hodometer.seldon.io
        - name: SCHEDULER_HOST
          value: seldon-scheduler
        - name: SCHEDULER_PLAINTXT_PORT
          value: "9004"
        - name: SCHEDULER_TLS_PORT
          value: "9044"
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        image: '{{ .Values.hodometer.image.registry }}/{{ .Values.hodometer.image.repository
          }}:{{.Values.hodometer.image.tag }}'
        imagePullPolicy: '{{ .Values.hodometer.image.pullPolicy }}'
        name: hodometer
        resources:
          limits:
            memory: '{{ .Values.hodometer.resources.memory }}'
          requests:
            cpu: '{{ .Values.hodometer.resources.cpu }}'
            memory: '{{ .Values.hodometer.resources.memory }}'
{{- with .Values.imagePullSecrets }}
      imagePullSecrets:
      {{- toYaml . | nindent 8 }}
{{- end }}
      securityContext: {{- toYaml .Values.hodometer.securityContext
        | nindent 8 }}
      serviceAccountName: hodometer
      terminationGracePeriodSeconds: 5
    replicas: 1
  - annotations: {{- toYaml .Values.envoy.annotations | nindent 8 }}
    labels: {{- toYaml .Values.envoy.labels | nindent 8 }}
    name: seldon-envoy
    podSpec:
      containers:
      - env:
        - name: ENVOY_SECURITY_PROTOCOL
          value: '{{ .Values.security.envoy.protocol }}'
        - name: ENVOY_XDS_CLIENT_TLS_KEY
          valueFrom:
            secretKeyRef:
              key: tls.key
              name: '{{ .Values.security.controlplane.ssl.client.secret }}'
              optional: true
        - name: ENVOY_XDS_CLIENT_TLS_CRT
          valueFrom:
            secretKeyRef:
              key: tls.crt
              name: '{{ .Values.security.controlplane.ssl.client.secret }}'
              optional: true
        - name: ENVOY_XDS_SERVER_TLS_CA
          valueFrom:
            secretKeyRef:
              key: ca.crt
              name: '{{ .Values.security.controlplane.ssl.client.serverValidationSecret
                }}'
              optional: true
        image: '{{ .Values.envoy.image.registry }}/{{ .Values.envoy.image.repository
          }}:{{ .Values.envoy.image.tag }}'
        imagePullPolicy: '{{ .Values.envoy.image.pullPolicy }}'
        lifecycle:
          preStop:
            exec:
              command:
              - /bin/sh
              - -c
              - |
                echo -ne "POST /healthcheck/fail HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n" > /dev/tcp/localhost/{{ .Values.envoy.adminInterfacePort }}
                sleep '{{ .Values.envoy.preStopSleepPeriodSeconds }}'
        name: envoy
        ports:
        - containerPort: 9000
          name: http
        - containerPort: 9003
          name: envoy-stats
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /ready
            port: envoy-stats
          initialDelaySeconds: 10
          periodSeconds: 5
        resources:
          limits:
            memory: '{{ .Values.envoy.resources.memory }}'
          requests:
            cpu: '{{ .Values.envoy.resources.cpu }}'
            memory: '{{ .Values.envoy.resources.memory }}'
{{- with .Values.imagePullSecrets }}
      imagePullSecrets:
      {{- toYaml . | nindent 8 }}
{{- end }}
      securityContext: {{- toYaml .Values.envoy.securityContext | nindent
        8 }}
      terminationGracePeriodSeconds: {{ .Values.envoy.terminationGracePeriodSeconds
        }}
    replicas: 1
  - annotations: {{- toYaml .Values.dataflow.annotations | nindent 8
      }}
    labels: {{- toYaml .Values.dataflow.labels | nindent 8 }}
    name: seldon-dataflow-engine
    podSpec:
      containers:
      - env:
        - name: SELDON_KAFKA_BOOTSTRAP_SERVERS
          value: '{{ .Values.kafka.bootstrap }}'
        - name: SELDON_KAFKA_CONSUMER_PREFIX
          value: '{{ .Values.kafka.consumerGroupIdPrefix }}'
        - name: SELDON_KAFKA_REPLICATION_FACTOR
          value: '{{ .Values.kafka.topics.replicationFactor }}'
        - name: SELDON_KAFKA_PARTITIONS_DEFAULT
          value: '{{ .Values.kafka.topics.numPartitions }}'
        - name: SELDON_KAFKA_MAX_MESSAGE_SIZE_BYTES
          value: '{{ int .Values.kafka.consumer.messageMaxBytes }}'
        - name: SELDON_KAFKA_SECURITY_PROTOCOL
          value: '{{ .Values.security.kafka.protocol }}'
        - name: SELDON_KAFKA_TLS_CLIENT_SECRET
          value: '{{ .Values.security.kafka.ssl.client.secret }}'
        - name: SELDON_KAFKA_TLS_CLIENT_KEY_PATH
          value: '{{ .Values.security.kafka.ssl.client.keyPath }}'
        - name: SELDON_KAFKA_TLS_CLIENT_CERT_PATH
          value: '{{ .Values.security.kafka.ssl.client.crtPath }}'
        - name: SELDON_KAFKA_TLS_CLIENT_CA_PATH
          value: '{{ .Values.security.kafka.ssl.client.caPath }}'
        - name: SELDON_KAFKA_TLS_BROKER_SECRET
          value: '{{ .Values.security.kafka.ssl.client.brokerValidationSecret }}'
        - name: SELDON_KAFKA_TLS_BROKER_CA_PATH
          value: '{{ .Values.security.kafka.ssl.client.brokerCaPath }}'
        - name: SELDON_KAFKA_TLS_ENDPOINT_IDENTIFICATION_ALGORITHM
          value: '{{ .Values.security.kafka.ssl.client.endpointIdentificationAlgorithm
            }}'
        - name: SELDON_KAFKA_SASL_MECHANISM
          value: '{{ .Values.security.kafka.sasl.mechanism }}'
        - name: SELDON_KAFKA_SASL_USERNAME
          value: '{{ .Values.security.kafka.sasl.client.username }}'
        - name: SELDON_KAFKA_SASL_SECRET
          value: '{{ .Values.security.kafka.sasl.client.secret }}'
        - name: SELDON_KAFKA_SASL_PASSWORD_PATH
          value: '{{ .Values.security.kafka.sasl.client.passwordPath }}'
        - name: SELDON_KAFKA_SCHEMA_REGISTRY_CONFIG_PATH
          value: '{{ .Values.security.schemaRegistry.configPath }}'
        - name: SELDON_TLS_ENDPOINT_IDENTIFICATION_ALGORITHM
          value: '{{ .Values.security.kafka.ssl.client.endpointIdentificationAlgorithm
            }}'
        - name: SELDON_CORES_COUNT
          value: '{{ .Values.dataflow.cores }}'
        - name: SELDON_LOG_LEVEL_APP
          value: '{{ hasKey .Values.dataflow "logLevel" | ternary .Values.dataflow.logLevel
            .Values.logging.logLevel | upper }}'
        - name: SELDON_LOG_LEVEL_KAFKA
          value: '{{ hasKey .Values.dataflow "logLevelKafka" | ternary .Values.dataflow.logLevelKafka
            .Values.logging.logLevel | upper }}'
        - name: SELDON_PIPELINE_CTLOPS_THREADS
          value: '{{ .Values.dataflow.pipelineCtlopsThreads }}'
        - name: SELDON_HEALTH_SERVER_PORT
          value: "8000"
        - name: SELDON_UPSTREAM_HOST
          value: seldon-scheduler
        - name: SELDON_UPSTREAM_PORT
          value: "9008"
        - name: OTEL_JAVAAGENT_ENABLED
          valueFrom:
            configMapKeyRef:
              key: OTEL_JAVAAGENT_ENABLED
              name: seldon-tracing
        - name: OTEL_EXPORTER_OTLP_ENDPOINT
          valueFrom:
            configMapKeyRef:
              key: OTEL_EXPORTER_OTLP_ENDPOINT
              name: seldon-tracing
        - name: OTEL_EXPORTER_OTLP_PROTOCOL
          valueFrom:
            configMapKeyRef:
              key: OTEL_EXPORTER_OTLP_PROTOCOL
              name: seldon-tracing
        - name: SELDON_POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        image: '{{ .Values.dataflow.image.registry }}/{{ .Values.dataflow.image.repository
          }}:{{ .Values.dataflow.image.tag }}'
        imagePullPolicy: '{{ .Values.dataflow.image.pullPolicy }}'
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /live
            port: health
          periodSeconds: 5
        name: dataflow-engine
        ports:
        - containerPort: 8000
          name: health
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /ready
            port: health
          periodSeconds: 5
        resources:
          limits:
            memory: '{{ .Values.dataflow.resources.memory }}'
          requests:
            cpu: '{{ .Values.dataflow.resources.cpu }}'
            memory: '{{ .Values.dataflow.resources.memory }}'
        startupProbe:
          failureThreshold: 10
          httpGet:
            path: /startup
            port: health
          initialDelaySeconds: 10
          periodSeconds: 10
        volumeMounts:
        - mountPath: /mnt/schema-registry
          name: kafka-schema-volume
          readOnly: true
{{- with .Values.imagePullSecrets }}
      imagePullSecrets:
      {{- toYaml . | nindent 8 }}
{{- end }}
      securityContext: {{- toYaml .Values.dataflow.securityContext |
        nindent 8 }}
      serviceAccountName: seldon-scheduler
      terminationGracePeriodSeconds: 5
      volumes:
      - name: kafka-schema-volume
        secret:
          optional: true
          secretName: confluent-schema
    replicas: 1
  config:
    agentConfig:
      rclone:
        config_secrets:
        - seldon-rclone-gs-public
    kafkaConfig:
      bootstrap.servers: '{{ .Values.kafka.bootstrap }}'
      consumer:
        auto.offset.reset: '{{ .Values.kafka.consumer.autoOffsetReset }}'
        message.max.bytes: '{{ int .Values.kafka.consumer.messageMaxBytes }}'
        session.timeout.ms: '{{ .Values.kafka.consumer.sessionTimeoutMs }}'
        topic.metadata.propagation.max.ms: '{{ .Values.kafka.consumer.topicMetadataPropagationMaxMs
          }}'
      consumerGroupIdPrefix: '{{ .Values.kafka.consumerGroupIdPrefix }}'
      debug: '{{ .Values.kafka.debug }}'
      producer:
        linger.ms: '{{ .Values.kafka.producer.lingerMs }}'
        message.max.bytes: '{{ int .Values.kafka.producer.messageMaxBytes }}'
      topicPrefix: '{{ .Values.kafka.topicPrefix }}'
      topics:
        numPartitions: '{{ .Values.kafka.topics.numPartitions }}'
        replicationFactor: '{{ .Values.kafka.topics.replicationFactor }}'
    scalingConfig:
      models:
        enabled: {{ .Values.autoscaling.autoscalingModelEnabled }}
      pipelines:
        maxShardCountMultiplier: {{ .Values.kafka.topics.numPartitions
          }}
      servers:
        enabled: {{ .Values.autoscaling.autoscalingServerEnabled }}
        scaleDownPackingEnabled: {{ .Values.autoscaling.serverPackingEnabled
          }}
        scaleDownPackingPercentage: {{ .Values.autoscaling.serverPackingPercentage
          }}
    serviceConfig:
      grpcServicePrefix: '{{ .Values.services.serviceGRPCPrefix }}'
      serviceType: '{{ .Values.services.defaultServiceType }}'
    tracingConfig:
      disable: {{ .Values.opentelemetry.disable }}
      otelExporterEndpoint: '{{ .Values.opentelemetry.endpoint }}'
      otelExporterProtocol: '{{ .Values.opentelemetry.protocol }}'
      ratio: '{{ .Values.opentelemetry.ratio }}'
---
apiVersion: mlops.seldon.io/v1alpha1
kind: ServerConfig
metadata:
  name: mlserver
  namespace: '{{ .Release.Namespace }}'
spec:
  podSpec:
    containers:
    - args:
      - rcd
      - --rc-no-auth
      - --config=/rclone/rclone.conf
      - --rc-addr=0.0.0.0:5572
      - --max-buffer-memory=$(MAX_BUFFER_MEMORY)
      command:
      - rclone
      env:
      - name: RCLONE_LOG_LEVEL
        value: '{{ hasKey .Values.serverConfig.rclone "logLevel" | ternary .Values.serverConfig.rclone.logLevel
          .Values.logging.logLevel | upper }}'
      - name: MAX_BUFFER_MEMORY
        value: 64M
      image: '{{ .Values.serverConfig.rclone.image.registry }}/{{ .Values.serverConfig.rclone.image.repository
        }}:{{ .Values.serverConfig.rclone.image.tag }}'
      imagePullPolicy: '{{ .Values.serverConfig.rclone.image.pullPolicy }}'
      lifecycle:
        preStop:
          httpGet:
            path: terminate
            port: 9007
      livenessProbe:
        exec:
          command:
          - rclone
          - rc
          - rc/noop
        failureThreshold: 1
        initialDelaySeconds: 5
        periodSeconds: 5
        successThreshold: 1
        timeoutSeconds: 1
      name: rclone
      ports:
      - containerPort: 5572
        name: rclone
        protocol: TCP
      readinessProbe:
        failureThreshold: 3
        initialDelaySeconds: 5
        periodSeconds: 5
        successThreshold: 1
        tcpSocket:
          port: 5572
        timeoutSeconds: 1
      resources:
        limits:
          memory: '{{ .Values.serverConfig.rclone.resources.limits.memory }}'
        requests:
          cpu: '{{ .Values.serverConfig.rclone.resources.cpu }}'
          memory: '{{ .Values.serverConfig.rclone.resources.memory }}'
      volumeMounts:
      - mountPath: /mnt/agent
        name: mlserver-models
    - args:
      - --tracing-config-path=/mnt/tracing/tracing.json
      command:
      - /bin/agent
      env:
      - name: SELDON_SERVER_CAPABILITIES
        value: '{{ .Values.serverConfig.mlserver.serverCapabilities }}'
      - name: SELDON_MODEL_INFERENCE_LAG_THRESHOLD
        value: '{{ .Values.serverConfig.agent.modelInferenceLagThreshold }}'
      - name: SELDON_MODEL_INACTIVE_SECONDS_THRESHOLD
        value: '{{ .Values.serverConfig.agent.modelInactiveSecondsThreshold }}'
      - name: SELDON_SCALING_STATS_PERIOD_SECONDS
        value: '{{ .Values.serverConfig.agent.scalingStatsPeriodSeconds }}'
      - name: SELDON_MAX_TIME_READY_SUB_SERVICE_AFTER_START_SECONDS
        value: '{{ .Values.serverConfig.agent.maxElapsedTimeReadySubServiceAfterStartSeconds
          }}'
      - name: SELDON_MAX_ELAPSED_TIME_READY_SUB_SERVICE_BEFORE_START_MINUTES
        value: '{{ .Values.serverConfig.agent.maxElapsedTimeReadySubServiceBeforeStartMinutes
          }}'
      - name: SELDON_PERIOD_READY_SUB_SERVICE_SECONDS
        value: '{{ .Values.serverConfig.agent.periodReadySubServiceSeconds }}'
      - name: SELDON_MAX_LOAD_ELAPSED_TIME_MINUTES
        value: '{{ .Values.serverConfig.agent.maxLoadElapsedTimeMinutes }}'
      - name: SELDON_MAX_UNLOAD_ELAPSED_TIME_MINUTES
        value: '{{ .Values.serverConfig.agent.maxUnloadElapsedTimeMinutes }}'
      - name: SELDON_MAX_LOAD_RETRY_COUNT
        value: '{{ .Values.serverConfig.agent.maxLoadRetryCount }}'
      - name: SELDON_MAX_UNLOAD_RETRY_COUNT
        value: '{{ .Values.serverConfig.agent.maxUnloadRetryCount }}'
      - name: SELDON_UNLOAD_GRACE_PERIOD_SECONDS
        value: '{{ .Values.serverConfig.agent.unloadGracePeriodSeconds }}'
      - name: SELDON_OVERCOMMIT_PERCENTAGE
        value: '{{ .Values.serverConfig.agent.overcommitPercentage }}'
      - name: CONTROL_PLANE_SECURITY_PROTOCOL
        value: '{{ .Values.security.controlplane.protocol }}'
      - name: CONTROL_PLANE_CLIENT_TLS_SECRET_NAME
        value: '{{ .Values.security.controlplane.ssl.client.secret }}'
      - name: CONTROL_PLANE_SERVER_TLS_SECRET_NAME
        value: '{{ .Values.security.controlplane.ssl.client.serverValidationSecret
          }}'
      - name: CONTROL_PLANE_CLIENT_TLS_KEY_LOCATION
        value: '{{ .Values.security.controlplane.ssl.client.keyPath }}'
      - name: CONTROL_PLANE_CLIENT_TLS_CRT_LOCATION
        value: '{{ .Values.security.controlplane.ssl.client.crtPath }}'
      - name: CONTROL_PLANE_CLIENT_TLS_CA_LOCATION
        value: '{{ .Values.security.controlplane.ssl.client.caPath }}'
      - name: CONTROL_PLANE_SERVER_TLS_CA_LOCATION
        value: '{{ .Values.security.controlplane.ssl.client.serverCaPath }}'
      - name: ENVOY_SECURITY_PROTOCOL
        value: '{{ .Values.security.envoy.protocol }}'
      - name: ENVOY_UPSTREAM_SERVER_TLS_SECRET_NAME
        value: '{{ .Values.security.envoy.ssl.upstream.server.secret }}'
      - name: ENVOY_UPSTREAM_CLIENT_TLS_SECRET_NAME
        value: '{{ .Values.security.envoy.ssl.upstream.server.clientValidationSecret
          }}'
      - name: ENVOY_UPSTREAM_SERVER_TLS_KEY_LOCATION
        value: '{{ .Values.security.envoy.ssl.upstream.server.keyPath }}'
      - name: ENVOY_UPSTREAM_SERVER_TLS_CRT_LOCATION
        value: '{{ .Values.security.envoy.ssl.upstream.server.crtPath }}'
      - name: ENVOY_UPSTREAM_SERVER_TLS_CA_LOCATION
        value: '{{ .Values.security.envoy.ssl.upstream.server.caPath }}'
      - name: ENVOY_UPSTREAM_CLIENT_TLS_CA_LOCATION
        value: '{{ .Values.security.envoy.ssl.upstream.server.clientCaPath }}'
      - name: MLSERVER_TRACING_SERVER
        value: '{{ .Values.opentelemetry.endpoint }}'
      - name: SELDON_LOG_LEVEL
        value: '{{ hasKey .Values.serverConfig.agent "logLevel" | ternary .Values.serverConfig.agent.logLevel
          .Values.logging.logLevel }}'
      - name: SELDON_USE_DEPLOYMENTS_FOR_SERVERS
        value: '{{ .Values.useDeploymentsForServers }}'
      - name: SELDON_SERVER_HTTP_PORT
        value: "9000"
      - name: SELDON_SERVER_GRPC_PORT
        value: "9500"
      - name: SELDON_REVERSE_PROXY_HTTP_PORT
        value: "9001"
      - name: SELDON_REVERSE_PROXY_GRPC_PORT
        value: "9501"
      - name: SELDON_SCHEDULER_HOST
        value: seldon-scheduler
      - name: SELDON_SCHEDULER_PORT
        value: "9005"
      - name: SELDON_SCHEDULER_TLS_PORT
        value: "9055"
      - name: SELDON_METRICS_PORT
        value: "9006"
      - name: SELDON_DRAINER_PORT
        value: "9007"
      - name: SELDON_READINESS_PORT
        value: "9008"
      - name: AGENT_TLS_SECRET_NAME
        value: ""
      - name: AGENT_TLS_FOLDER_PATH
        value: ""
      - name: SELDON_SERVER_TYPE
        value: mlserver
      - name: SELDON_ENVOY_HOST
        value: seldon-mesh
      - name: SELDON_ENVOY_PORT
        value: "80"
      - name: POD_NAME
        valueFrom:
          fieldRef:
            fieldPath: metadata.name
      - name: POD_NAMESPACE
        valueFrom:
          fieldRef:
            fieldPath: metadata.namespace
      - name: MEMORY_REQUEST
        valueFrom:
          resourceFieldRef:
            containerName: mlserver
            resource: requests.memory
      image: '{{ .Values.serverConfig.agent.image.registry }}/{{ .Values.serverConfig.agent.image.repository
        }}:{{ .Values.serverConfig.agent.image.tag }}'
      imagePullPolicy: '{{ .Values.serverConfig.agent.image.pullPolicy }}'
      lifecycle:
        preStop:
          httpGet:
            path: terminate
            port: 9007
      name: agent
      ports:
      - containerPort: 9501
        name: grpc
        protocol: TCP
      - containerPort: 9001
        name: http
        protocol: TCP
      - containerPort: 9006
        name: metrics
        protocol: TCP
      - containerPort: 9008
        name: readiness-port
      readinessProbe:
        failureThreshold: 1
        httpGet:
          path: /ready
          port: 9008
        periodSeconds: 5
      resources:
        limits:
          memory: '{{ .Values.serverConfig.agent.resources.memory }}'
        requests:
          cpu: '{{ .Values.serverConfig.agent.resources.cpu }}'
          memory: '{{ .Values.serverConfig.agent.resources.memory }}'
      startupProbe:
        failureThreshold: 60
        httpGet:
          path: /ready
          port: 9008
        periodSeconds: 15
      volumeMounts:
      - mountPath: /mnt/agent
        name: mlserver-models
      - mountPath: /mnt/config
        name: config-volume
      - mountPath: /mnt/tracing
        name: tracing-config-volume
    - env:
      - name: MLSERVER_HTTP_PORT
        value: "9000"
      - name: MLSERVER_GRPC_PORT
        value: "9500"
      - name: MLSERVER_MODELS_DIR
        value: /mnt/agent/models
      - name: MLSERVER_MODEL_PARALLEL_WORKERS
        value: "1"
      - name: MLSERVER_LOAD_MODELS_AT_STARTUP
        value: "false"
      - name: MLSERVER_GRPC_MAX_MESSAGE_LENGTH
        value: "1048576000"
      image: '{{ .Values.serverConfig.mlserver.image.registry }}/{{ .Values.serverConfig.mlserver.image.repository
        }}:{{ .Values.serverConfig.mlserver.image.tag }}'
      imagePullPolicy: '{{ .Values.serverConfig.mlserver.image.pullPolicy }}'
      lifecycle:
        preStop:
          httpGet:
            path: terminate
            port: 9007
      livenessProbe:
        httpGet:
          path: /v2/health/live
          port: server-http
      name: mlserver
      ports:
      - containerPort: 9500
        name: server-grpc
        protocol: TCP
      - containerPort: 9000
        name: server-http
        protocol: TCP
      - containerPort: 8082
        name: server-metrics
      readinessProbe:
        httpGet:
          path: /v2/health/live
          port: server-http
        initialDelaySeconds: 5
        periodSeconds: 5
      resources:
        limits:
          memory: '{{ .Values.serverConfig.mlserver.resources.memory }}'
        requests:
          cpu: '{{ .Values.serverConfig.mlserver.resources.cpu }}'
          memory: '{{ .Values.serverConfig.mlserver.resources.memory }}'
      startupProbe:
        failureThreshold: 10
        httpGet:
          path: /v2/health/live
          port: server-http
        periodSeconds: 10
      volumeMounts:
      - mountPath: /mnt/agent
        name: mlserver-models
        readOnly: true
      - mountPath: /mnt/certs
        name: downstream-ca-certs
        readOnly: true
{{- with .Values.imagePullSecrets }}
    imagePullSecrets:
    {{- toYaml . | nindent 8 }}
{{- end }}
    securityContext: {{- toYaml .Values.serverConfig.securityContext
      | nindent 6 }}
    serviceAccountName: seldon-server
    terminationGracePeriodSeconds: {{ .Values.serverConfig.terminationGracePeriodSeconds
      }}
    volumes:
    - name: downstream-ca-certs
      secret:
        optional: true
        secretName: '{{ .Values.security.envoy.ssl.downstream.client.serverValidationSecret
          }}'
    - configMap:
        name: seldon-agent
      name: config-volume
    - configMap:
        name: seldon-tracing
      name: tracing-config-volume
  volumeClaimTemplates:
  - name: mlserver-models
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: '{{ .Values.serverConfig.mlserver.modelVolumeStorage }}'
---
apiVersion: mlops.seldon.io/v1alpha1
kind: ServerConfig
metadata:
  name: triton
  namespace: '{{ .Release.Namespace }}'
spec:
  podSpec:
    containers:
    - args:
      - rcd
      - --rc-no-auth
      - --config=/rclone/rclone.conf
      - --rc-addr=0.0.0.0:5572
      - --max-buffer-memory=$(MAX_BUFFER_MEMORY)
      command:
      - rclone
      env:
      - name: RCLONE_LOG_LEVEL
        value: '{{ hasKey .Values.serverConfig.rclone "logLevel" | ternary .Values.serverConfig.rclone.logLevel
          .Values.logging.logLevel | upper }}'
      - name: MAX_BUFFER_MEMORY
        value: 64M
      image: '{{ .Values.serverConfig.rclone.image.registry }}/{{ .Values.serverConfig.rclone.image.repository
        }}:{{ .Values.serverConfig.rclone.image.tag }}'
      imagePullPolicy: '{{ .Values.serverConfig.rclone.image.pullPolicy }}'
      lifecycle:
        preStop:
          httpGet:
            path: terminate
            port: 9007
      livenessProbe:
        exec:
          command:
          - rclone
          - rc
          - rc/noop
        failureThreshold: 1
        initialDelaySeconds: 5
        periodSeconds: 5
        successThreshold: 1
        timeoutSeconds: 1
      name: rclone
      ports:
      - containerPort: 5572
        name: rclone
        protocol: TCP
      readinessProbe:
        failureThreshold: 3
        initialDelaySeconds: 5
        periodSeconds: 5
        successThreshold: 1
        tcpSocket:
          port: 5572
        timeoutSeconds: 1
      resources:
        limits:
          memory: '{{ .Values.serverConfig.rclone.resources.limits.memory }}'
        requests:
          cpu: '{{ .Values.serverConfig.rclone.resources.cpu }}'
          memory: '{{ .Values.serverConfig.rclone.resources.memory }}'
      volumeMounts:
      - mountPath: /mnt/agent
        name: triton-models
    - args:
      - --tracing-config-path=/mnt/tracing/tracing.json
      command:
      - /bin/agent
      env:
      - name: SELDON_SERVER_CAPABILITIES
        value: '{{ .Values.serverConfig.triton.serverCapabilities }}'
      - name: SELDON_MODEL_INFERENCE_LAG_THRESHOLD
        value: '{{ .Values.serverConfig.agent.modelInferenceLagThreshold }}'
      - name: SELDON_MODEL_INACTIVE_SECONDS_THRESHOLD
        value: '{{ .Values.serverConfig.agent.modelInactiveSecondsThreshold }}'
      - name: SELDON_SCALING_STATS_PERIOD_SECONDS
        value: '{{ .Values.serverConfig.agent.scalingStatsPeriodSeconds }}'
      - name: SELDON_MAX_TIME_READY_SUB_SERVICE_AFTER_START_SECONDS
        value: '{{ .Values.serverConfig.agent.maxElapsedTimeReadySubServiceAfterStartSeconds
          }}'
      - name: SELDON_MAX_ELAPSED_TIME_READY_SUB_SERVICE_BEFORE_START_MINUTES
        value: '{{ .Values.serverConfig.agent.maxElapsedTimeReadySubServiceBeforeStartMinutes
          }}'
      - name: SELDON_PERIOD_READY_SUB_SERVICE_SECONDS
        value: '{{ .Values.serverConfig.agent.periodReadySubServiceSeconds }}'
      - name: SELDON_MAX_LOAD_ELAPSED_TIME_MINUTES
        value: '{{ .Values.serverConfig.agent.maxLoadElapsedTimeMinutes }}'
      - name: SELDON_MAX_UNLOAD_ELAPSED_TIME_MINUTES
        value: '{{ .Values.serverConfig.agent.maxUnloadElapsedTimeMinutes }}'
      - name: SELDON_MAX_LOAD_RETRY_COUNT
        value: '{{ .Values.serverConfig.agent.maxLoadRetryCount }}'
      - name: SELDON_MAX_UNLOAD_RETRY_COUNT
        value: '{{ .Values.serverConfig.agent.maxUnloadRetryCount }}'
      - name: SELDON_UNLOAD_GRACE_PERIOD_SECONDS
        value: '{{ .Values.serverConfig.agent.unloadGracePeriodSeconds }}'
      - name: SELDON_OVERCOMMIT_PERCENTAGE
        value: '{{ .Values.serverConfig.agent.overcommitPercentage }}'
      - name: CONTROL_PLANE_SECURITY_PROTOCOL
        value: '{{ .Values.security.controlplane.protocol }}'
      - name: CONTROL_PLANE_CLIENT_TLS_SECRET_NAME
        value: '{{ .Values.security.controlplane.ssl.client.secret }}'
      - name: CONTROL_PLANE_SERVER_TLS_SECRET_NAME
        value: '{{ .Values.security.controlplane.ssl.client.serverValidationSecret
          }}'
      - name: CONTROL_PLANE_CLIENT_TLS_KEY_LOCATION
        value: '{{ .Values.security.controlplane.ssl.client.keyPath }}'
      - name: CONTROL_PLANE_CLIENT_TLS_CRT_LOCATION
        value: '{{ .Values.security.controlplane.ssl.client.crtPath }}'
      - name: CONTROL_PLANE_CLIENT_TLS_CA_LOCATION
        value: '{{ .Values.security.controlplane.ssl.client.caPath }}'
      - name: CONTROL_PLANE_SERVER_TLS_CA_LOCATION
        value: '{{ .Values.security.controlplane.ssl.client.serverCaPath }}'
      - name: ENVOY_SECURITY_PROTOCOL
        value: '{{ .Values.security.envoy.protocol }}'
      - name: ENVOY_UPSTREAM_SERVER_TLS_SECRET_NAME
        value: '{{ .Values.security.envoy.ssl.upstream.server.secret }}'
      - name: ENVOY_UPSTREAM_CLIENT_TLS_SECRET_NAME
        value: '{{ .Values.security.envoy.ssl.upstream.server.clientValidationSecret
          }}'
      - name: ENVOY_UPSTREAM_SERVER_TLS_KEY_LOCATION
        value: '{{ .Values.security.envoy.ssl.upstream.server.keyPath }}'
      - name: ENVOY_UPSTREAM_SERVER_TLS_CRT_LOCATION
        value: '{{ .Values.security.envoy.ssl.upstream.server.crtPath }}'
      - name: ENVOY_UPSTREAM_SERVER_TLS_CA_LOCATION
        value: '{{ .Values.security.envoy.ssl.upstream.server.caPath }}'
      - name: ENVOY_UPSTREAM_CLIENT_TLS_CA_LOCATION
        value: '{{ .Values.security.envoy.ssl.upstream.server.clientCaPath }}'
      - name: SELDON_LOG_LEVEL
        value: '{{ hasKey .Values.serverConfig.agent "logLevel" | ternary .Values.serverConfig.agent.logLevel
          .Values.logging.logLevel }}'
      - name: SELDON_USE_DEPLOYMENTS_FOR_SERVERS
        value: '{{ .Values.useDeploymentsForServers }}'
      - name: SELDON_SERVER_HTTP_PORT
        value: "9000"
      - name: SELDON_SERVER_GRPC_PORT
        value: "9500"
      - name: SELDON_REVERSE_PROXY_HTTP_PORT
        value: "9001"
      - name: SELDON_REVERSE_PROXY_GRPC_PORT
        value: "9501"
      - name: AGENT_TLS_SECRET_NAME
        value: ""
      - name: AGENT_TLS_FOLDER_PATH
        value: ""
      - name: SELDON_SCHEDULER_HOST
        value: seldon-scheduler
      - name: SELDON_SCHEDULER_PORT
        value: "9005"
      - name: SELDON_METRICS_PORT
        value: "9006"
      - name: SELDON_DRAINER_PORT
        value: "9007"
      - name: SELDON_READINESS_PORT
        value: "9008"
      - name: SELDON_SERVER_TYPE
        value: triton
      - name: POD_NAME
        valueFrom:
          fieldRef:
            fieldPath: metadata.name
      - name: POD_NAMESPACE
        valueFrom:
          fieldRef:
            fieldPath: metadata.namespace
      - name: MEMORY_REQUEST
        valueFrom:
          resourceFieldRef:
            containerName: triton
            resource: requests.memory
      image: '{{ .Values.serverConfig.agent.image.registry }}/{{ .Values.serverConfig.agent.image.repository
        }}:{{ .Values.serverConfig.agent.image.tag }}'
      imagePullPolicy: '{{ .Values.serverConfig.agent.image.pullPolicy }}'
      lifecycle:
        preStop:
          httpGet:
            path: terminate
            port: 9007
      name: agent
      ports:
      - containerPort: 9501
        name: grpc
        protocol: TCP
      - containerPort: 9001
        name: http
        protocol: TCP
      - containerPort: 9006
        name: metrics
        protocol: TCP
      - containerPort: 9008
        name: readiness-port
      readinessProbe:
        failureThreshold: 1
        httpGet:
          path: /ready
          port: 9008
        periodSeconds: 5
      resources:
        limits:
          memory: '{{ .Values.serverConfig.agent.resources.memory }}'
        requests:
          cpu: '{{ .Values.serverConfig.agent.resources.cpu }}'
          memory: '{{ .Values.serverConfig.agent.resources.memory }}'
      startupProbe:
        failureThreshold: 60
        httpGet:
          path: /ready
          port: 9008
        periodSeconds: 15
      volumeMounts:
      - mountPath: /mnt/agent
        name: triton-models
      - mountPath: /mnt/config
        name: config-volume
      - mountPath: /mnt/tracing
        name: tracing-config-volume
    - args:
      - -c
      - tritonserver --model-repository=$(SERVER_MODELS_DIR) --http-port=$(SERVER_HTTP_PORT)
        --grpc-port=$(SERVER_GRPC_PORT) --log-verbose=1 --model-control-mode=explicit
        --backend-config=python,shm-default-byte-size=16777216
      command:
      - bash
      env:
      - name: SERVER_HTTP_PORT
        value: "9000"
      - name: SERVER_GRPC_PORT
        value: "9500"
      - name: SERVER_MODELS_DIR
        value: /mnt/agent/models
      - name: LD_PRELOAD
        value: /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
      image: '{{ .Values.serverConfig.triton.image.registry }}/{{ .Values.serverConfig.triton.image.repository
        }}:{{ .Values.serverConfig.triton.image.tag }}'
      imagePullPolicy: '{{ .Values.serverConfig.triton.image.pullPolicy }}'
      lifecycle:
        preStop:
          httpGet:
            path: terminate
            port: 9007
      livenessProbe:
        httpGet:
          path: /v2/health/live
          port: server-http
      name: triton
      ports:
      - containerPort: 9500
        name: server-grpc
        protocol: TCP
      - containerPort: 9000
        name: server-http
        protocol: TCP
      - containerPort: 8002
        name: server-metrics
      readinessProbe:
        httpGet:
          path: /v2/health/live
          port: server-http
        initialDelaySeconds: 5
        periodSeconds: 5
      resources:
        limits:
          memory: '{{ .Values.serverConfig.triton.resources.memory }}'
        requests:
          cpu: '{{ .Values.serverConfig.triton.resources.cpu }}'
          memory: '{{ .Values.serverConfig.triton.resources.memory }}'
      startupProbe:
        failureThreshold: 10
        httpGet:
          path: /v2/health/live
          port: server-http
        periodSeconds: 10
      volumeMounts:
      - mountPath: /mnt/agent
        name: triton-models
        readOnly: true
      - mountPath: /dev/shm
        name: dshm
        readOnly: false
{{- with .Values.imagePullSecrets }}
    imagePullSecrets:
    {{- toYaml . | nindent 8 }}
{{- end }}
    securityContext: {{- toYaml .Values.serverConfig.securityContext
      | nindent 6 }}
    serviceAccountName: seldon-server
    terminationGracePeriodSeconds: {{ .Values.serverConfig.terminationGracePeriodSeconds
      }}
    volumes:
    - configMap:
        name: seldon-agent
      name: config-volume
    - configMap:
        name: seldon-tracing
      name: tracing-config-volume
    - emptyDir:
        medium: Memory
        sizeLimit: 256Mi
      name: dshm
  volumeClaimTemplates:
  - name: triton-models
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: '{{ .Values.serverConfig.triton.modelVolumeStorage }}'
{{- end }}
